# Maintainer: Andrew Chadwick <a.t.chadwick@gmail.com>

_realname=graphene
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.8.0
pkgrel=1
arch=('any')
pkgdesc="A thin layer of types for graphic libraries (mingw-w64)"
depends=("${MINGW_PACKAGE_PREFIX}-glib2")
makedepends=("${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection")
options=('strip' '!debug')
license=("MIT")
url="https://ebassi.github.io/graphene/"
source=("${_realname}-${pkgver}.tar.gz::https://github.com/ebassi/graphene/archive/${pkgver}.tar.gz")
sha256sums=('410f2e848952cc5830f39b6f6ea7f9b0a487cfe99dad86eec6f22ccbb3ec635b')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}
}

build() {
  [[ -d build-${MINGW_CHOST} ]] && rm -rf build-${MINGW_CHOST}
  mkdir -p build-${MINGW_CHOST}
  cd build-${MINGW_CHOST}

  meson \
    --buildtype release \
    ../${_realname}-${pkgver}

  ninja

  sed -s "s|$(cygpath -m ${MINGW_PREFIX})|${MINGW_PREFIX}|g" -i src/graphene-1.0.pc
  sed -s "s|$(cygpath -m ${MINGW_PREFIX})|${MINGW_PREFIX}|g" -i src/graphene-gobject-1.0.pc

}

check() {
  cd "${srcdir}/build-${MINGW_CHOST}"

  ninja test
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  DESTDIR=${pkgdir}${MINGW_PREFIX} ninja install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/LICENSE" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
